package com.oedtech.esl.handler;

import com.oedtech.esl.json.JsonResult;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 权限拒绝访问handle
 */
@Component
public class AjaxAccessDeniedHandler implements AccessDeniedHandler {


    @Override
    public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, org.springframework.security.access.AccessDeniedException e) throws IOException, ServletException {
        JsonResult jr=new JsonResult("error","permission denied");
        httpServletResponse.getWriter().write(JSONObject.fromObject(jr).toString());
    }
}